
user/_uthread:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <thread_init>:
struct thread *current_thread;
extern void thread_switch(uint64, uint64);
              
void 
thread_init(void)
{
   0:	1141                	addi	sp,sp,-16
   2:	e422                	sd	s0,8(sp)
   4:	0800                	addi	s0,sp,16
  // main() is thread 0, which will make the first invocation to
  // thread_schedule().  it needs a stack so that the first thread_switch() can
  // save thread 0's state.  thread_schedule() won't run the main thread ever
  // again, because its state is set to RUNNING, and thread_schedule() selects
  // a RUNNABLE thread.
  current_thread = &all_thread[0];
   6:	00001797          	auipc	a5,0x1
   a:	d1278793          	addi	a5,a5,-750 # d18 <all_thread>
   e:	00001717          	auipc	a4,0x1
  12:	cef73d23          	sd	a5,-774(a4) # d08 <current_thread>
  current_thread->state = RUNNING;
  16:	4785                	li	a5,1
  18:	00003717          	auipc	a4,0x3
  1c:	d0f72023          	sw	a5,-768(a4) # 2d18 <__global_pointer$+0x1828>
}
  20:	6422                	ld	s0,8(sp)
  22:	0141                	addi	sp,sp,16
  24:	8082                	ret

0000000000000026 <thread_schedule>:
{
  struct thread *t, *next_thread;

  /* Find another runnable thread. */
  next_thread = 0;
  t = current_thread + 1;
  26:	00001797          	auipc	a5,0x1
  2a:	ce278793          	addi	a5,a5,-798 # d08 <current_thread>
  2e:	0007b883          	ld	a7,0(a5)
  32:	6789                	lui	a5,0x2
  34:	0791                	addi	a5,a5,4
  36:	97c6                	add	a5,a5,a7
  38:	4711                	li	a4,4
  for(int i = 0; i < MAX_THREAD; i++){
    if(t >= all_thread + MAX_THREAD)
  3a:	00009517          	auipc	a0,0x9
  3e:	cee50513          	addi	a0,a0,-786 # 8d28 <base>
      t = all_thread;
    if(t->state == RUNNABLE) {
  42:	6609                	lui	a2,0x2
  44:	4589                	li	a1,2
      next_thread = t;
      break;
    }
    t = t + 1;
  46:	00460813          	addi	a6,a2,4 # 2004 <__global_pointer$+0xb14>
  4a:	a809                	j	5c <thread_schedule+0x36>
    if(t->state == RUNNABLE) {
  4c:	00c786b3          	add	a3,a5,a2
  50:	4294                	lw	a3,0(a3)
  52:	02b68d63          	beq	a3,a1,8c <thread_schedule+0x66>
    t = t + 1;
  56:	97c2                	add	a5,a5,a6
  for(int i = 0; i < MAX_THREAD; i++){
  58:	377d                	addiw	a4,a4,-1
  5a:	cb01                	beqz	a4,6a <thread_schedule+0x44>
    if(t >= all_thread + MAX_THREAD)
  5c:	fea7e8e3          	bltu	a5,a0,4c <thread_schedule+0x26>
      t = all_thread;
  60:	00001797          	auipc	a5,0x1
  64:	cb878793          	addi	a5,a5,-840 # d18 <all_thread>
  68:	b7d5                	j	4c <thread_schedule+0x26>
{
  6a:	1141                	addi	sp,sp,-16
  6c:	e406                	sd	ra,8(sp)
  6e:	e022                	sd	s0,0(sp)
  70:	0800                	addi	s0,sp,16
  }

  if (next_thread == 0) {
    printf("thread_schedule: no runnable threads\n");
  72:	00001517          	auipc	a0,0x1
  76:	b5e50513          	addi	a0,a0,-1186 # bd0 <malloc+0xea>
  7a:	00001097          	auipc	ra,0x1
  7e:	9ac080e7          	jalr	-1620(ra) # a26 <printf>
    exit(-1);
  82:	557d                	li	a0,-1
  84:	00000097          	auipc	ra,0x0
  88:	622080e7          	jalr	1570(ra) # 6a6 <exit>
  }

  if (current_thread != next_thread) {         /* switch threads?  */
  8c:	00f88b63          	beq	a7,a5,a2 <thread_schedule+0x7c>
    next_thread->state = RUNNING;
  90:	6709                	lui	a4,0x2
  92:	973e                	add	a4,a4,a5
  94:	4685                	li	a3,1
  96:	c314                	sw	a3,0(a4)
    t = current_thread;
    current_thread = next_thread;
  98:	00001717          	auipc	a4,0x1
  9c:	c6f73823          	sd	a5,-912(a4) # d08 <current_thread>
     * Invoke thread_switch to switch from t to next_thread:
     * thread_switch(??, ??);
     */
  } else
    next_thread = 0;
}
  a0:	8082                	ret
  a2:	8082                	ret

00000000000000a4 <thread_create>:

void 
thread_create(void (*func)())
{
  a4:	1141                	addi	sp,sp,-16
  a6:	e422                	sd	s0,8(sp)
  a8:	0800                	addi	s0,sp,16
  struct thread *t;

  for (t = all_thread; t < all_thread + MAX_THREAD; t++) {
    if (t->state == FREE) break;
  aa:	00003797          	auipc	a5,0x3
  ae:	c6e78793          	addi	a5,a5,-914 # 2d18 <__global_pointer$+0x1828>
  b2:	439c                	lw	a5,0(a5)
  b4:	cb95                	beqz	a5,e8 <thread_create+0x44>
  for (t = all_thread; t < all_thread + MAX_THREAD; t++) {
  b6:	00003797          	auipc	a5,0x3
  ba:	c6678793          	addi	a5,a5,-922 # 2d1c <__global_pointer$+0x182c>
    if (t->state == FREE) break;
  be:	6689                	lui	a3,0x2
  for (t = all_thread; t < all_thread + MAX_THREAD; t++) {
  c0:	00468593          	addi	a1,a3,4 # 2004 <__global_pointer$+0xb14>
  c4:	00009617          	auipc	a2,0x9
  c8:	c6460613          	addi	a2,a2,-924 # 8d28 <base>
    if (t->state == FREE) break;
  cc:	00d78733          	add	a4,a5,a3
  d0:	4318                	lw	a4,0(a4)
  d2:	c701                	beqz	a4,da <thread_create+0x36>
  for (t = all_thread; t < all_thread + MAX_THREAD; t++) {
  d4:	97ae                	add	a5,a5,a1
  d6:	fec79be3          	bne	a5,a2,cc <thread_create+0x28>
  }
  t->state = RUNNABLE;
  da:	6709                	lui	a4,0x2
  dc:	97ba                	add	a5,a5,a4
  de:	4709                	li	a4,2
  e0:	c398                	sw	a4,0(a5)
  // YOUR CODE HERE
}
  e2:	6422                	ld	s0,8(sp)
  e4:	0141                	addi	sp,sp,16
  e6:	8082                	ret
  for (t = all_thread; t < all_thread + MAX_THREAD; t++) {
  e8:	00001797          	auipc	a5,0x1
  ec:	c3078793          	addi	a5,a5,-976 # d18 <all_thread>
  f0:	b7ed                	j	da <thread_create+0x36>

00000000000000f2 <thread_yield>:

void 
thread_yield(void)
{
  f2:	1141                	addi	sp,sp,-16
  f4:	e406                	sd	ra,8(sp)
  f6:	e022                	sd	s0,0(sp)
  f8:	0800                	addi	s0,sp,16
  current_thread->state = RUNNABLE;
  fa:	00001797          	auipc	a5,0x1
  fe:	c0e78793          	addi	a5,a5,-1010 # d08 <current_thread>
 102:	639c                	ld	a5,0(a5)
 104:	6709                	lui	a4,0x2
 106:	97ba                	add	a5,a5,a4
 108:	4709                	li	a4,2
 10a:	c398                	sw	a4,0(a5)
  thread_schedule();
 10c:	00000097          	auipc	ra,0x0
 110:	f1a080e7          	jalr	-230(ra) # 26 <thread_schedule>
}
 114:	60a2                	ld	ra,8(sp)
 116:	6402                	ld	s0,0(sp)
 118:	0141                	addi	sp,sp,16
 11a:	8082                	ret

000000000000011c <thread_a>:
volatile int a_started, b_started, c_started;
volatile int a_n, b_n, c_n;

void 
thread_a(void)
{
 11c:	7179                	addi	sp,sp,-48
 11e:	f406                	sd	ra,40(sp)
 120:	f022                	sd	s0,32(sp)
 122:	ec26                	sd	s1,24(sp)
 124:	e84a                	sd	s2,16(sp)
 126:	e44e                	sd	s3,8(sp)
 128:	e052                	sd	s4,0(sp)
 12a:	1800                	addi	s0,sp,48
  int i;
  printf("thread_a started\n");
 12c:	00001517          	auipc	a0,0x1
 130:	acc50513          	addi	a0,a0,-1332 # bf8 <malloc+0x112>
 134:	00001097          	auipc	ra,0x1
 138:	8f2080e7          	jalr	-1806(ra) # a26 <printf>
  a_started = 1;
 13c:	4785                	li	a5,1
 13e:	00001717          	auipc	a4,0x1
 142:	bcf72323          	sw	a5,-1082(a4) # d04 <a_started>
  while(b_started == 0 || c_started == 0)
 146:	00001497          	auipc	s1,0x1
 14a:	bba48493          	addi	s1,s1,-1094 # d00 <b_started>
 14e:	00001917          	auipc	s2,0x1
 152:	bae90913          	addi	s2,s2,-1106 # cfc <c_started>
 156:	a029                	j	160 <thread_a+0x44>
    thread_yield();
 158:	00000097          	auipc	ra,0x0
 15c:	f9a080e7          	jalr	-102(ra) # f2 <thread_yield>
  while(b_started == 0 || c_started == 0)
 160:	409c                	lw	a5,0(s1)
 162:	2781                	sext.w	a5,a5
 164:	dbf5                	beqz	a5,158 <thread_a+0x3c>
 166:	00092783          	lw	a5,0(s2)
 16a:	2781                	sext.w	a5,a5
 16c:	d7f5                	beqz	a5,158 <thread_a+0x3c>
  
  for (i = 0; i < 100; i++) {
 16e:	4481                	li	s1,0
    printf("thread_a %d\n", i);
 170:	00001a17          	auipc	s4,0x1
 174:	aa0a0a13          	addi	s4,s4,-1376 # c10 <malloc+0x12a>
    a_n += 1;
 178:	00001917          	auipc	s2,0x1
 17c:	b8090913          	addi	s2,s2,-1152 # cf8 <a_n>
  for (i = 0; i < 100; i++) {
 180:	06400993          	li	s3,100
    printf("thread_a %d\n", i);
 184:	85a6                	mv	a1,s1
 186:	8552                	mv	a0,s4
 188:	00001097          	auipc	ra,0x1
 18c:	89e080e7          	jalr	-1890(ra) # a26 <printf>
    a_n += 1;
 190:	00092783          	lw	a5,0(s2)
 194:	2785                	addiw	a5,a5,1
 196:	00f92023          	sw	a5,0(s2)
    thread_yield();
 19a:	00000097          	auipc	ra,0x0
 19e:	f58080e7          	jalr	-168(ra) # f2 <thread_yield>
  for (i = 0; i < 100; i++) {
 1a2:	2485                	addiw	s1,s1,1
 1a4:	ff3490e3          	bne	s1,s3,184 <thread_a+0x68>
  }
  printf("thread_a: exit after %d\n", a_n);
 1a8:	00001797          	auipc	a5,0x1
 1ac:	b5078793          	addi	a5,a5,-1200 # cf8 <a_n>
 1b0:	438c                	lw	a1,0(a5)
 1b2:	2581                	sext.w	a1,a1
 1b4:	00001517          	auipc	a0,0x1
 1b8:	a6c50513          	addi	a0,a0,-1428 # c20 <malloc+0x13a>
 1bc:	00001097          	auipc	ra,0x1
 1c0:	86a080e7          	jalr	-1942(ra) # a26 <printf>

  current_thread->state = FREE;
 1c4:	00001797          	auipc	a5,0x1
 1c8:	b4478793          	addi	a5,a5,-1212 # d08 <current_thread>
 1cc:	639c                	ld	a5,0(a5)
 1ce:	6709                	lui	a4,0x2
 1d0:	97ba                	add	a5,a5,a4
 1d2:	0007a023          	sw	zero,0(a5)
  thread_schedule();
 1d6:	00000097          	auipc	ra,0x0
 1da:	e50080e7          	jalr	-432(ra) # 26 <thread_schedule>
}
 1de:	70a2                	ld	ra,40(sp)
 1e0:	7402                	ld	s0,32(sp)
 1e2:	64e2                	ld	s1,24(sp)
 1e4:	6942                	ld	s2,16(sp)
 1e6:	69a2                	ld	s3,8(sp)
 1e8:	6a02                	ld	s4,0(sp)
 1ea:	6145                	addi	sp,sp,48
 1ec:	8082                	ret

00000000000001ee <thread_b>:

void 
thread_b(void)
{
 1ee:	7179                	addi	sp,sp,-48
 1f0:	f406                	sd	ra,40(sp)
 1f2:	f022                	sd	s0,32(sp)
 1f4:	ec26                	sd	s1,24(sp)
 1f6:	e84a                	sd	s2,16(sp)
 1f8:	e44e                	sd	s3,8(sp)
 1fa:	e052                	sd	s4,0(sp)
 1fc:	1800                	addi	s0,sp,48
  int i;
  printf("thread_b started\n");
 1fe:	00001517          	auipc	a0,0x1
 202:	a4250513          	addi	a0,a0,-1470 # c40 <malloc+0x15a>
 206:	00001097          	auipc	ra,0x1
 20a:	820080e7          	jalr	-2016(ra) # a26 <printf>
  b_started = 1;
 20e:	4785                	li	a5,1
 210:	00001717          	auipc	a4,0x1
 214:	aef72823          	sw	a5,-1296(a4) # d00 <b_started>
  while(a_started == 0 || c_started == 0)
 218:	00001497          	auipc	s1,0x1
 21c:	aec48493          	addi	s1,s1,-1300 # d04 <a_started>
 220:	00001917          	auipc	s2,0x1
 224:	adc90913          	addi	s2,s2,-1316 # cfc <c_started>
 228:	a029                	j	232 <thread_b+0x44>
    thread_yield();
 22a:	00000097          	auipc	ra,0x0
 22e:	ec8080e7          	jalr	-312(ra) # f2 <thread_yield>
  while(a_started == 0 || c_started == 0)
 232:	409c                	lw	a5,0(s1)
 234:	2781                	sext.w	a5,a5
 236:	dbf5                	beqz	a5,22a <thread_b+0x3c>
 238:	00092783          	lw	a5,0(s2)
 23c:	2781                	sext.w	a5,a5
 23e:	d7f5                	beqz	a5,22a <thread_b+0x3c>
  
  for (i = 0; i < 100; i++) {
 240:	4481                	li	s1,0
    printf("thread_b %d\n", i);
 242:	00001a17          	auipc	s4,0x1
 246:	a16a0a13          	addi	s4,s4,-1514 # c58 <malloc+0x172>
    b_n += 1;
 24a:	00001917          	auipc	s2,0x1
 24e:	aaa90913          	addi	s2,s2,-1366 # cf4 <b_n>
  for (i = 0; i < 100; i++) {
 252:	06400993          	li	s3,100
    printf("thread_b %d\n", i);
 256:	85a6                	mv	a1,s1
 258:	8552                	mv	a0,s4
 25a:	00000097          	auipc	ra,0x0
 25e:	7cc080e7          	jalr	1996(ra) # a26 <printf>
    b_n += 1;
 262:	00092783          	lw	a5,0(s2)
 266:	2785                	addiw	a5,a5,1
 268:	00f92023          	sw	a5,0(s2)
    thread_yield();
 26c:	00000097          	auipc	ra,0x0
 270:	e86080e7          	jalr	-378(ra) # f2 <thread_yield>
  for (i = 0; i < 100; i++) {
 274:	2485                	addiw	s1,s1,1
 276:	ff3490e3          	bne	s1,s3,256 <thread_b+0x68>
  }
  printf("thread_b: exit after %d\n", b_n);
 27a:	00001797          	auipc	a5,0x1
 27e:	a7a78793          	addi	a5,a5,-1414 # cf4 <b_n>
 282:	438c                	lw	a1,0(a5)
 284:	2581                	sext.w	a1,a1
 286:	00001517          	auipc	a0,0x1
 28a:	9e250513          	addi	a0,a0,-1566 # c68 <malloc+0x182>
 28e:	00000097          	auipc	ra,0x0
 292:	798080e7          	jalr	1944(ra) # a26 <printf>

  current_thread->state = FREE;
 296:	00001797          	auipc	a5,0x1
 29a:	a7278793          	addi	a5,a5,-1422 # d08 <current_thread>
 29e:	639c                	ld	a5,0(a5)
 2a0:	6709                	lui	a4,0x2
 2a2:	97ba                	add	a5,a5,a4
 2a4:	0007a023          	sw	zero,0(a5)
  thread_schedule();
 2a8:	00000097          	auipc	ra,0x0
 2ac:	d7e080e7          	jalr	-642(ra) # 26 <thread_schedule>
}
 2b0:	70a2                	ld	ra,40(sp)
 2b2:	7402                	ld	s0,32(sp)
 2b4:	64e2                	ld	s1,24(sp)
 2b6:	6942                	ld	s2,16(sp)
 2b8:	69a2                	ld	s3,8(sp)
 2ba:	6a02                	ld	s4,0(sp)
 2bc:	6145                	addi	sp,sp,48
 2be:	8082                	ret

00000000000002c0 <thread_c>:

void 
thread_c(void)
{
 2c0:	7179                	addi	sp,sp,-48
 2c2:	f406                	sd	ra,40(sp)
 2c4:	f022                	sd	s0,32(sp)
 2c6:	ec26                	sd	s1,24(sp)
 2c8:	e84a                	sd	s2,16(sp)
 2ca:	e44e                	sd	s3,8(sp)
 2cc:	e052                	sd	s4,0(sp)
 2ce:	1800                	addi	s0,sp,48
  int i;
  printf("thread_c started\n");
 2d0:	00001517          	auipc	a0,0x1
 2d4:	9b850513          	addi	a0,a0,-1608 # c88 <malloc+0x1a2>
 2d8:	00000097          	auipc	ra,0x0
 2dc:	74e080e7          	jalr	1870(ra) # a26 <printf>
  c_started = 1;
 2e0:	4785                	li	a5,1
 2e2:	00001717          	auipc	a4,0x1
 2e6:	a0f72d23          	sw	a5,-1510(a4) # cfc <c_started>
  while(a_started == 0 || b_started == 0)
 2ea:	00001497          	auipc	s1,0x1
 2ee:	a1a48493          	addi	s1,s1,-1510 # d04 <a_started>
 2f2:	00001917          	auipc	s2,0x1
 2f6:	a0e90913          	addi	s2,s2,-1522 # d00 <b_started>
 2fa:	a029                	j	304 <thread_c+0x44>
    thread_yield();
 2fc:	00000097          	auipc	ra,0x0
 300:	df6080e7          	jalr	-522(ra) # f2 <thread_yield>
  while(a_started == 0 || b_started == 0)
 304:	409c                	lw	a5,0(s1)
 306:	2781                	sext.w	a5,a5
 308:	dbf5                	beqz	a5,2fc <thread_c+0x3c>
 30a:	00092783          	lw	a5,0(s2)
 30e:	2781                	sext.w	a5,a5
 310:	d7f5                	beqz	a5,2fc <thread_c+0x3c>
  
  for (i = 0; i < 100; i++) {
 312:	4481                	li	s1,0
    printf("thread_c %d\n", i);
 314:	00001a17          	auipc	s4,0x1
 318:	98ca0a13          	addi	s4,s4,-1652 # ca0 <malloc+0x1ba>
    c_n += 1;
 31c:	00001917          	auipc	s2,0x1
 320:	9d490913          	addi	s2,s2,-1580 # cf0 <c_n>
  for (i = 0; i < 100; i++) {
 324:	06400993          	li	s3,100
    printf("thread_c %d\n", i);
 328:	85a6                	mv	a1,s1
 32a:	8552                	mv	a0,s4
 32c:	00000097          	auipc	ra,0x0
 330:	6fa080e7          	jalr	1786(ra) # a26 <printf>
    c_n += 1;
 334:	00092783          	lw	a5,0(s2)
 338:	2785                	addiw	a5,a5,1
 33a:	00f92023          	sw	a5,0(s2)
    thread_yield();
 33e:	00000097          	auipc	ra,0x0
 342:	db4080e7          	jalr	-588(ra) # f2 <thread_yield>
  for (i = 0; i < 100; i++) {
 346:	2485                	addiw	s1,s1,1
 348:	ff3490e3          	bne	s1,s3,328 <thread_c+0x68>
  }
  printf("thread_c: exit after %d\n", c_n);
 34c:	00001797          	auipc	a5,0x1
 350:	9a478793          	addi	a5,a5,-1628 # cf0 <c_n>
 354:	438c                	lw	a1,0(a5)
 356:	2581                	sext.w	a1,a1
 358:	00001517          	auipc	a0,0x1
 35c:	95850513          	addi	a0,a0,-1704 # cb0 <malloc+0x1ca>
 360:	00000097          	auipc	ra,0x0
 364:	6c6080e7          	jalr	1734(ra) # a26 <printf>

  current_thread->state = FREE;
 368:	00001797          	auipc	a5,0x1
 36c:	9a078793          	addi	a5,a5,-1632 # d08 <current_thread>
 370:	639c                	ld	a5,0(a5)
 372:	6709                	lui	a4,0x2
 374:	97ba                	add	a5,a5,a4
 376:	0007a023          	sw	zero,0(a5)
  thread_schedule();
 37a:	00000097          	auipc	ra,0x0
 37e:	cac080e7          	jalr	-852(ra) # 26 <thread_schedule>
}
 382:	70a2                	ld	ra,40(sp)
 384:	7402                	ld	s0,32(sp)
 386:	64e2                	ld	s1,24(sp)
 388:	6942                	ld	s2,16(sp)
 38a:	69a2                	ld	s3,8(sp)
 38c:	6a02                	ld	s4,0(sp)
 38e:	6145                	addi	sp,sp,48
 390:	8082                	ret

0000000000000392 <main>:

int 
main(int argc, char *argv[]) 
{
 392:	1141                	addi	sp,sp,-16
 394:	e406                	sd	ra,8(sp)
 396:	e022                	sd	s0,0(sp)
 398:	0800                	addi	s0,sp,16
  a_started = b_started = c_started = 0;
 39a:	00001797          	auipc	a5,0x1
 39e:	9607a123          	sw	zero,-1694(a5) # cfc <c_started>
 3a2:	00001797          	auipc	a5,0x1
 3a6:	9407af23          	sw	zero,-1698(a5) # d00 <b_started>
 3aa:	00001797          	auipc	a5,0x1
 3ae:	9407ad23          	sw	zero,-1702(a5) # d04 <a_started>
  a_n = b_n = c_n = 0;
 3b2:	00001797          	auipc	a5,0x1
 3b6:	9207af23          	sw	zero,-1730(a5) # cf0 <c_n>
 3ba:	00001797          	auipc	a5,0x1
 3be:	9207ad23          	sw	zero,-1734(a5) # cf4 <b_n>
 3c2:	00001797          	auipc	a5,0x1
 3c6:	9207ab23          	sw	zero,-1738(a5) # cf8 <a_n>
  thread_init();
 3ca:	00000097          	auipc	ra,0x0
 3ce:	c36080e7          	jalr	-970(ra) # 0 <thread_init>
  thread_create(thread_a);
 3d2:	00000517          	auipc	a0,0x0
 3d6:	d4a50513          	addi	a0,a0,-694 # 11c <thread_a>
 3da:	00000097          	auipc	ra,0x0
 3de:	cca080e7          	jalr	-822(ra) # a4 <thread_create>
  thread_create(thread_b);
 3e2:	00000517          	auipc	a0,0x0
 3e6:	e0c50513          	addi	a0,a0,-500 # 1ee <thread_b>
 3ea:	00000097          	auipc	ra,0x0
 3ee:	cba080e7          	jalr	-838(ra) # a4 <thread_create>
  thread_create(thread_c);
 3f2:	00000517          	auipc	a0,0x0
 3f6:	ece50513          	addi	a0,a0,-306 # 2c0 <thread_c>
 3fa:	00000097          	auipc	ra,0x0
 3fe:	caa080e7          	jalr	-854(ra) # a4 <thread_create>
  thread_schedule();
 402:	00000097          	auipc	ra,0x0
 406:	c24080e7          	jalr	-988(ra) # 26 <thread_schedule>
  exit(0);
 40a:	4501                	li	a0,0
 40c:	00000097          	auipc	ra,0x0
 410:	29a080e7          	jalr	666(ra) # 6a6 <exit>

0000000000000414 <thread_switch>:
 414:	8082                	ret

0000000000000416 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
 416:	1141                	addi	sp,sp,-16
 418:	e422                	sd	s0,8(sp)
 41a:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 41c:	87aa                	mv	a5,a0
 41e:	0585                	addi	a1,a1,1
 420:	0785                	addi	a5,a5,1
 422:	fff5c703          	lbu	a4,-1(a1)
 426:	fee78fa3          	sb	a4,-1(a5)
 42a:	fb75                	bnez	a4,41e <strcpy+0x8>
    ;
  return os;
}
 42c:	6422                	ld	s0,8(sp)
 42e:	0141                	addi	sp,sp,16
 430:	8082                	ret

0000000000000432 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 432:	1141                	addi	sp,sp,-16
 434:	e422                	sd	s0,8(sp)
 436:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 438:	00054783          	lbu	a5,0(a0)
 43c:	cf91                	beqz	a5,458 <strcmp+0x26>
 43e:	0005c703          	lbu	a4,0(a1)
 442:	00f71b63          	bne	a4,a5,458 <strcmp+0x26>
    p++, q++;
 446:	0505                	addi	a0,a0,1
 448:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 44a:	00054783          	lbu	a5,0(a0)
 44e:	c789                	beqz	a5,458 <strcmp+0x26>
 450:	0005c703          	lbu	a4,0(a1)
 454:	fef709e3          	beq	a4,a5,446 <strcmp+0x14>
  return (uchar)*p - (uchar)*q;
 458:	0005c503          	lbu	a0,0(a1)
}
 45c:	40a7853b          	subw	a0,a5,a0
 460:	6422                	ld	s0,8(sp)
 462:	0141                	addi	sp,sp,16
 464:	8082                	ret

0000000000000466 <strlen>:

uint
strlen(const char *s)
{
 466:	1141                	addi	sp,sp,-16
 468:	e422                	sd	s0,8(sp)
 46a:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
 46c:	00054783          	lbu	a5,0(a0)
 470:	cf91                	beqz	a5,48c <strlen+0x26>
 472:	0505                	addi	a0,a0,1
 474:	87aa                	mv	a5,a0
 476:	4685                	li	a3,1
 478:	9e89                	subw	a3,a3,a0
 47a:	00f6853b          	addw	a0,a3,a5
 47e:	0785                	addi	a5,a5,1
 480:	fff7c703          	lbu	a4,-1(a5)
 484:	fb7d                	bnez	a4,47a <strlen+0x14>
    ;
  return n;
}
 486:	6422                	ld	s0,8(sp)
 488:	0141                	addi	sp,sp,16
 48a:	8082                	ret
  for(n = 0; s[n]; n++)
 48c:	4501                	li	a0,0
 48e:	bfe5                	j	486 <strlen+0x20>

0000000000000490 <memset>:

void*
memset(void *dst, int c, uint n)
{
 490:	1141                	addi	sp,sp,-16
 492:	e422                	sd	s0,8(sp)
 494:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 496:	ce09                	beqz	a2,4b0 <memset+0x20>
 498:	87aa                	mv	a5,a0
 49a:	fff6071b          	addiw	a4,a2,-1
 49e:	1702                	slli	a4,a4,0x20
 4a0:	9301                	srli	a4,a4,0x20
 4a2:	0705                	addi	a4,a4,1
 4a4:	972a                	add	a4,a4,a0
    cdst[i] = c;
 4a6:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 4aa:	0785                	addi	a5,a5,1
 4ac:	fee79de3          	bne	a5,a4,4a6 <memset+0x16>
  }
  return dst;
}
 4b0:	6422                	ld	s0,8(sp)
 4b2:	0141                	addi	sp,sp,16
 4b4:	8082                	ret

00000000000004b6 <strchr>:

char*
strchr(const char *s, char c)
{
 4b6:	1141                	addi	sp,sp,-16
 4b8:	e422                	sd	s0,8(sp)
 4ba:	0800                	addi	s0,sp,16
  for(; *s; s++)
 4bc:	00054783          	lbu	a5,0(a0)
 4c0:	cf91                	beqz	a5,4dc <strchr+0x26>
    if(*s == c)
 4c2:	00f58a63          	beq	a1,a5,4d6 <strchr+0x20>
  for(; *s; s++)
 4c6:	0505                	addi	a0,a0,1
 4c8:	00054783          	lbu	a5,0(a0)
 4cc:	c781                	beqz	a5,4d4 <strchr+0x1e>
    if(*s == c)
 4ce:	feb79ce3          	bne	a5,a1,4c6 <strchr+0x10>
 4d2:	a011                	j	4d6 <strchr+0x20>
      return (char*)s;
  return 0;
 4d4:	4501                	li	a0,0
}
 4d6:	6422                	ld	s0,8(sp)
 4d8:	0141                	addi	sp,sp,16
 4da:	8082                	ret
  return 0;
 4dc:	4501                	li	a0,0
 4de:	bfe5                	j	4d6 <strchr+0x20>

00000000000004e0 <gets>:

char*
gets(char *buf, int max)
{
 4e0:	711d                	addi	sp,sp,-96
 4e2:	ec86                	sd	ra,88(sp)
 4e4:	e8a2                	sd	s0,80(sp)
 4e6:	e4a6                	sd	s1,72(sp)
 4e8:	e0ca                	sd	s2,64(sp)
 4ea:	fc4e                	sd	s3,56(sp)
 4ec:	f852                	sd	s4,48(sp)
 4ee:	f456                	sd	s5,40(sp)
 4f0:	f05a                	sd	s6,32(sp)
 4f2:	ec5e                	sd	s7,24(sp)
 4f4:	1080                	addi	s0,sp,96
 4f6:	8baa                	mv	s7,a0
 4f8:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 4fa:	892a                	mv	s2,a0
 4fc:	4981                	li	s3,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 4fe:	4aa9                	li	s5,10
 500:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 502:	0019849b          	addiw	s1,s3,1
 506:	0344d863          	ble	s4,s1,536 <gets+0x56>
    cc = read(0, &c, 1);
 50a:	4605                	li	a2,1
 50c:	faf40593          	addi	a1,s0,-81
 510:	4501                	li	a0,0
 512:	00000097          	auipc	ra,0x0
 516:	1ac080e7          	jalr	428(ra) # 6be <read>
    if(cc < 1)
 51a:	00a05e63          	blez	a0,536 <gets+0x56>
    buf[i++] = c;
 51e:	faf44783          	lbu	a5,-81(s0)
 522:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 526:	01578763          	beq	a5,s5,534 <gets+0x54>
 52a:	0905                	addi	s2,s2,1
  for(i=0; i+1 < max; ){
 52c:	89a6                	mv	s3,s1
    if(c == '\n' || c == '\r')
 52e:	fd679ae3          	bne	a5,s6,502 <gets+0x22>
 532:	a011                	j	536 <gets+0x56>
  for(i=0; i+1 < max; ){
 534:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 536:	99de                	add	s3,s3,s7
 538:	00098023          	sb	zero,0(s3)
  return buf;
}
 53c:	855e                	mv	a0,s7
 53e:	60e6                	ld	ra,88(sp)
 540:	6446                	ld	s0,80(sp)
 542:	64a6                	ld	s1,72(sp)
 544:	6906                	ld	s2,64(sp)
 546:	79e2                	ld	s3,56(sp)
 548:	7a42                	ld	s4,48(sp)
 54a:	7aa2                	ld	s5,40(sp)
 54c:	7b02                	ld	s6,32(sp)
 54e:	6be2                	ld	s7,24(sp)
 550:	6125                	addi	sp,sp,96
 552:	8082                	ret

0000000000000554 <stat>:

int
stat(const char *n, struct stat *st)
{
 554:	1101                	addi	sp,sp,-32
 556:	ec06                	sd	ra,24(sp)
 558:	e822                	sd	s0,16(sp)
 55a:	e426                	sd	s1,8(sp)
 55c:	e04a                	sd	s2,0(sp)
 55e:	1000                	addi	s0,sp,32
 560:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 562:	4581                	li	a1,0
 564:	00000097          	auipc	ra,0x0
 568:	182080e7          	jalr	386(ra) # 6e6 <open>
  if(fd < 0)
 56c:	02054563          	bltz	a0,596 <stat+0x42>
 570:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 572:	85ca                	mv	a1,s2
 574:	00000097          	auipc	ra,0x0
 578:	18a080e7          	jalr	394(ra) # 6fe <fstat>
 57c:	892a                	mv	s2,a0
  close(fd);
 57e:	8526                	mv	a0,s1
 580:	00000097          	auipc	ra,0x0
 584:	14e080e7          	jalr	334(ra) # 6ce <close>
  return r;
}
 588:	854a                	mv	a0,s2
 58a:	60e2                	ld	ra,24(sp)
 58c:	6442                	ld	s0,16(sp)
 58e:	64a2                	ld	s1,8(sp)
 590:	6902                	ld	s2,0(sp)
 592:	6105                	addi	sp,sp,32
 594:	8082                	ret
    return -1;
 596:	597d                	li	s2,-1
 598:	bfc5                	j	588 <stat+0x34>

000000000000059a <atoi>:

int
atoi(const char *s)
{
 59a:	1141                	addi	sp,sp,-16
 59c:	e422                	sd	s0,8(sp)
 59e:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 5a0:	00054683          	lbu	a3,0(a0)
 5a4:	fd06879b          	addiw	a5,a3,-48
 5a8:	0ff7f793          	andi	a5,a5,255
 5ac:	4725                	li	a4,9
 5ae:	02f76963          	bltu	a4,a5,5e0 <atoi+0x46>
 5b2:	862a                	mv	a2,a0
  n = 0;
 5b4:	4501                	li	a0,0
  while('0' <= *s && *s <= '9')
 5b6:	45a5                	li	a1,9
    n = n*10 + *s++ - '0';
 5b8:	0605                	addi	a2,a2,1
 5ba:	0025179b          	slliw	a5,a0,0x2
 5be:	9fa9                	addw	a5,a5,a0
 5c0:	0017979b          	slliw	a5,a5,0x1
 5c4:	9fb5                	addw	a5,a5,a3
 5c6:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 5ca:	00064683          	lbu	a3,0(a2)
 5ce:	fd06871b          	addiw	a4,a3,-48
 5d2:	0ff77713          	andi	a4,a4,255
 5d6:	fee5f1e3          	bleu	a4,a1,5b8 <atoi+0x1e>
  return n;
}
 5da:	6422                	ld	s0,8(sp)
 5dc:	0141                	addi	sp,sp,16
 5de:	8082                	ret
  n = 0;
 5e0:	4501                	li	a0,0
 5e2:	bfe5                	j	5da <atoi+0x40>

00000000000005e4 <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
 5e4:	1141                	addi	sp,sp,-16
 5e6:	e422                	sd	s0,8(sp)
 5e8:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
 5ea:	02b57663          	bleu	a1,a0,616 <memmove+0x32>
    while(n-- > 0)
 5ee:	02c05163          	blez	a2,610 <memmove+0x2c>
 5f2:	fff6079b          	addiw	a5,a2,-1
 5f6:	1782                	slli	a5,a5,0x20
 5f8:	9381                	srli	a5,a5,0x20
 5fa:	0785                	addi	a5,a5,1
 5fc:	97aa                	add	a5,a5,a0
  dst = vdst;
 5fe:	872a                	mv	a4,a0
      *dst++ = *src++;
 600:	0585                	addi	a1,a1,1
 602:	0705                	addi	a4,a4,1
 604:	fff5c683          	lbu	a3,-1(a1)
 608:	fed70fa3          	sb	a3,-1(a4) # 1fff <__global_pointer$+0xb0f>
    while(n-- > 0)
 60c:	fee79ae3          	bne	a5,a4,600 <memmove+0x1c>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 610:	6422                	ld	s0,8(sp)
 612:	0141                	addi	sp,sp,16
 614:	8082                	ret
    dst += n;
 616:	00c50733          	add	a4,a0,a2
    src += n;
 61a:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 61c:	fec05ae3          	blez	a2,610 <memmove+0x2c>
 620:	fff6079b          	addiw	a5,a2,-1
 624:	1782                	slli	a5,a5,0x20
 626:	9381                	srli	a5,a5,0x20
 628:	fff7c793          	not	a5,a5
 62c:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 62e:	15fd                	addi	a1,a1,-1
 630:	177d                	addi	a4,a4,-1
 632:	0005c683          	lbu	a3,0(a1)
 636:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 63a:	fef71ae3          	bne	a4,a5,62e <memmove+0x4a>
 63e:	bfc9                	j	610 <memmove+0x2c>

0000000000000640 <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
 640:	1141                	addi	sp,sp,-16
 642:	e422                	sd	s0,8(sp)
 644:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 646:	ce15                	beqz	a2,682 <memcmp+0x42>
 648:	fff6069b          	addiw	a3,a2,-1
    if (*p1 != *p2) {
 64c:	00054783          	lbu	a5,0(a0)
 650:	0005c703          	lbu	a4,0(a1)
 654:	02e79063          	bne	a5,a4,674 <memcmp+0x34>
 658:	1682                	slli	a3,a3,0x20
 65a:	9281                	srli	a3,a3,0x20
 65c:	0685                	addi	a3,a3,1
 65e:	96aa                	add	a3,a3,a0
      return *p1 - *p2;
    }
    p1++;
 660:	0505                	addi	a0,a0,1
    p2++;
 662:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 664:	00d50d63          	beq	a0,a3,67e <memcmp+0x3e>
    if (*p1 != *p2) {
 668:	00054783          	lbu	a5,0(a0)
 66c:	0005c703          	lbu	a4,0(a1)
 670:	fee788e3          	beq	a5,a4,660 <memcmp+0x20>
      return *p1 - *p2;
 674:	40e7853b          	subw	a0,a5,a4
  }
  return 0;
}
 678:	6422                	ld	s0,8(sp)
 67a:	0141                	addi	sp,sp,16
 67c:	8082                	ret
  return 0;
 67e:	4501                	li	a0,0
 680:	bfe5                	j	678 <memcmp+0x38>
 682:	4501                	li	a0,0
 684:	bfd5                	j	678 <memcmp+0x38>

0000000000000686 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 686:	1141                	addi	sp,sp,-16
 688:	e406                	sd	ra,8(sp)
 68a:	e022                	sd	s0,0(sp)
 68c:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 68e:	00000097          	auipc	ra,0x0
 692:	f56080e7          	jalr	-170(ra) # 5e4 <memmove>
}
 696:	60a2                	ld	ra,8(sp)
 698:	6402                	ld	s0,0(sp)
 69a:	0141                	addi	sp,sp,16
 69c:	8082                	ret

000000000000069e <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 69e:	4885                	li	a7,1
 ecall
 6a0:	00000073          	ecall
 ret
 6a4:	8082                	ret

00000000000006a6 <exit>:
.global exit
exit:
 li a7, SYS_exit
 6a6:	4889                	li	a7,2
 ecall
 6a8:	00000073          	ecall
 ret
 6ac:	8082                	ret

00000000000006ae <wait>:
.global wait
wait:
 li a7, SYS_wait
 6ae:	488d                	li	a7,3
 ecall
 6b0:	00000073          	ecall
 ret
 6b4:	8082                	ret

00000000000006b6 <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 6b6:	4891                	li	a7,4
 ecall
 6b8:	00000073          	ecall
 ret
 6bc:	8082                	ret

00000000000006be <read>:
.global read
read:
 li a7, SYS_read
 6be:	4895                	li	a7,5
 ecall
 6c0:	00000073          	ecall
 ret
 6c4:	8082                	ret

00000000000006c6 <write>:
.global write
write:
 li a7, SYS_write
 6c6:	48c1                	li	a7,16
 ecall
 6c8:	00000073          	ecall
 ret
 6cc:	8082                	ret

00000000000006ce <close>:
.global close
close:
 li a7, SYS_close
 6ce:	48d5                	li	a7,21
 ecall
 6d0:	00000073          	ecall
 ret
 6d4:	8082                	ret

00000000000006d6 <kill>:
.global kill
kill:
 li a7, SYS_kill
 6d6:	4899                	li	a7,6
 ecall
 6d8:	00000073          	ecall
 ret
 6dc:	8082                	ret

00000000000006de <exec>:
.global exec
exec:
 li a7, SYS_exec
 6de:	489d                	li	a7,7
 ecall
 6e0:	00000073          	ecall
 ret
 6e4:	8082                	ret

00000000000006e6 <open>:
.global open
open:
 li a7, SYS_open
 6e6:	48bd                	li	a7,15
 ecall
 6e8:	00000073          	ecall
 ret
 6ec:	8082                	ret

00000000000006ee <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 6ee:	48c5                	li	a7,17
 ecall
 6f0:	00000073          	ecall
 ret
 6f4:	8082                	ret

00000000000006f6 <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 6f6:	48c9                	li	a7,18
 ecall
 6f8:	00000073          	ecall
 ret
 6fc:	8082                	ret

00000000000006fe <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 6fe:	48a1                	li	a7,8
 ecall
 700:	00000073          	ecall
 ret
 704:	8082                	ret

0000000000000706 <link>:
.global link
link:
 li a7, SYS_link
 706:	48cd                	li	a7,19
 ecall
 708:	00000073          	ecall
 ret
 70c:	8082                	ret

000000000000070e <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 70e:	48d1                	li	a7,20
 ecall
 710:	00000073          	ecall
 ret
 714:	8082                	ret

0000000000000716 <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 716:	48a5                	li	a7,9
 ecall
 718:	00000073          	ecall
 ret
 71c:	8082                	ret

000000000000071e <dup>:
.global dup
dup:
 li a7, SYS_dup
 71e:	48a9                	li	a7,10
 ecall
 720:	00000073          	ecall
 ret
 724:	8082                	ret

0000000000000726 <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 726:	48ad                	li	a7,11
 ecall
 728:	00000073          	ecall
 ret
 72c:	8082                	ret

000000000000072e <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 72e:	48b1                	li	a7,12
 ecall
 730:	00000073          	ecall
 ret
 734:	8082                	ret

0000000000000736 <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 736:	48b5                	li	a7,13
 ecall
 738:	00000073          	ecall
 ret
 73c:	8082                	ret

000000000000073e <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 73e:	48b9                	li	a7,14
 ecall
 740:	00000073          	ecall
 ret
 744:	8082                	ret

0000000000000746 <ntas>:
.global ntas
ntas:
 li a7, SYS_ntas
 746:	48d9                	li	a7,22
 ecall
 748:	00000073          	ecall
 ret
 74c:	8082                	ret

000000000000074e <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
 74e:	1101                	addi	sp,sp,-32
 750:	ec06                	sd	ra,24(sp)
 752:	e822                	sd	s0,16(sp)
 754:	1000                	addi	s0,sp,32
 756:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 75a:	4605                	li	a2,1
 75c:	fef40593          	addi	a1,s0,-17
 760:	00000097          	auipc	ra,0x0
 764:	f66080e7          	jalr	-154(ra) # 6c6 <write>
}
 768:	60e2                	ld	ra,24(sp)
 76a:	6442                	ld	s0,16(sp)
 76c:	6105                	addi	sp,sp,32
 76e:	8082                	ret

0000000000000770 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 770:	7139                	addi	sp,sp,-64
 772:	fc06                	sd	ra,56(sp)
 774:	f822                	sd	s0,48(sp)
 776:	f426                	sd	s1,40(sp)
 778:	f04a                	sd	s2,32(sp)
 77a:	ec4e                	sd	s3,24(sp)
 77c:	0080                	addi	s0,sp,64
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 77e:	c299                	beqz	a3,784 <printint+0x14>
 780:	0005cd63          	bltz	a1,79a <printint+0x2a>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 784:	2581                	sext.w	a1,a1
  neg = 0;
 786:	4301                	li	t1,0
 788:	fc040713          	addi	a4,s0,-64
  }

  i = 0;
 78c:	4801                	li	a6,0
  do{
    buf[i++] = digits[x % base];
 78e:	2601                	sext.w	a2,a2
 790:	00000897          	auipc	a7,0x0
 794:	54088893          	addi	a7,a7,1344 # cd0 <digits>
 798:	a801                	j	7a8 <printint+0x38>
    x = -xx;
 79a:	40b005bb          	negw	a1,a1
 79e:	2581                	sext.w	a1,a1
    neg = 1;
 7a0:	4305                	li	t1,1
    x = -xx;
 7a2:	b7dd                	j	788 <printint+0x18>
  }while((x /= base) != 0);
 7a4:	85be                	mv	a1,a5
    buf[i++] = digits[x % base];
 7a6:	8836                	mv	a6,a3
 7a8:	0018069b          	addiw	a3,a6,1
 7ac:	02c5f7bb          	remuw	a5,a1,a2
 7b0:	1782                	slli	a5,a5,0x20
 7b2:	9381                	srli	a5,a5,0x20
 7b4:	97c6                	add	a5,a5,a7
 7b6:	0007c783          	lbu	a5,0(a5)
 7ba:	00f70023          	sb	a5,0(a4)
  }while((x /= base) != 0);
 7be:	0705                	addi	a4,a4,1
 7c0:	02c5d7bb          	divuw	a5,a1,a2
 7c4:	fec5f0e3          	bleu	a2,a1,7a4 <printint+0x34>
  if(neg)
 7c8:	00030b63          	beqz	t1,7de <printint+0x6e>
    buf[i++] = '-';
 7cc:	fd040793          	addi	a5,s0,-48
 7d0:	96be                	add	a3,a3,a5
 7d2:	02d00793          	li	a5,45
 7d6:	fef68823          	sb	a5,-16(a3)
 7da:	0028069b          	addiw	a3,a6,2

  while(--i >= 0)
 7de:	02d05963          	blez	a3,810 <printint+0xa0>
 7e2:	89aa                	mv	s3,a0
 7e4:	fc040793          	addi	a5,s0,-64
 7e8:	00d784b3          	add	s1,a5,a3
 7ec:	fff78913          	addi	s2,a5,-1
 7f0:	9936                	add	s2,s2,a3
 7f2:	36fd                	addiw	a3,a3,-1
 7f4:	1682                	slli	a3,a3,0x20
 7f6:	9281                	srli	a3,a3,0x20
 7f8:	40d90933          	sub	s2,s2,a3
    putc(fd, buf[i]);
 7fc:	fff4c583          	lbu	a1,-1(s1)
 800:	854e                	mv	a0,s3
 802:	00000097          	auipc	ra,0x0
 806:	f4c080e7          	jalr	-180(ra) # 74e <putc>
  while(--i >= 0)
 80a:	14fd                	addi	s1,s1,-1
 80c:	ff2498e3          	bne	s1,s2,7fc <printint+0x8c>
}
 810:	70e2                	ld	ra,56(sp)
 812:	7442                	ld	s0,48(sp)
 814:	74a2                	ld	s1,40(sp)
 816:	7902                	ld	s2,32(sp)
 818:	69e2                	ld	s3,24(sp)
 81a:	6121                	addi	sp,sp,64
 81c:	8082                	ret

000000000000081e <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 81e:	7119                	addi	sp,sp,-128
 820:	fc86                	sd	ra,120(sp)
 822:	f8a2                	sd	s0,112(sp)
 824:	f4a6                	sd	s1,104(sp)
 826:	f0ca                	sd	s2,96(sp)
 828:	ecce                	sd	s3,88(sp)
 82a:	e8d2                	sd	s4,80(sp)
 82c:	e4d6                	sd	s5,72(sp)
 82e:	e0da                	sd	s6,64(sp)
 830:	fc5e                	sd	s7,56(sp)
 832:	f862                	sd	s8,48(sp)
 834:	f466                	sd	s9,40(sp)
 836:	f06a                	sd	s10,32(sp)
 838:	ec6e                	sd	s11,24(sp)
 83a:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
 83c:	0005c483          	lbu	s1,0(a1)
 840:	18048d63          	beqz	s1,9da <vprintf+0x1bc>
 844:	8aaa                	mv	s5,a0
 846:	8b32                	mv	s6,a2
 848:	00158913          	addi	s2,a1,1
  state = 0;
 84c:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 84e:	02500a13          	li	s4,37
      if(c == 'd'){
 852:	06400c13          	li	s8,100
        printint(fd, va_arg(ap, int), 10, 1);
      } else if(c == 'l') {
 856:	06c00c93          	li	s9,108
        printint(fd, va_arg(ap, uint64), 10, 0);
      } else if(c == 'x') {
 85a:	07800d13          	li	s10,120
        printint(fd, va_arg(ap, int), 16, 0);
      } else if(c == 'p') {
 85e:	07000d93          	li	s11,112
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 862:	00000b97          	auipc	s7,0x0
 866:	46eb8b93          	addi	s7,s7,1134 # cd0 <digits>
 86a:	a839                	j	888 <vprintf+0x6a>
        putc(fd, c);
 86c:	85a6                	mv	a1,s1
 86e:	8556                	mv	a0,s5
 870:	00000097          	auipc	ra,0x0
 874:	ede080e7          	jalr	-290(ra) # 74e <putc>
 878:	a019                	j	87e <vprintf+0x60>
    } else if(state == '%'){
 87a:	01498f63          	beq	s3,s4,898 <vprintf+0x7a>
  for(i = 0; fmt[i]; i++){
 87e:	0905                	addi	s2,s2,1
 880:	fff94483          	lbu	s1,-1(s2)
 884:	14048b63          	beqz	s1,9da <vprintf+0x1bc>
    c = fmt[i] & 0xff;
 888:	0004879b          	sext.w	a5,s1
    if(state == 0){
 88c:	fe0997e3          	bnez	s3,87a <vprintf+0x5c>
      if(c == '%'){
 890:	fd479ee3          	bne	a5,s4,86c <vprintf+0x4e>
        state = '%';
 894:	89be                	mv	s3,a5
 896:	b7e5                	j	87e <vprintf+0x60>
      if(c == 'd'){
 898:	05878063          	beq	a5,s8,8d8 <vprintf+0xba>
      } else if(c == 'l') {
 89c:	05978c63          	beq	a5,s9,8f4 <vprintf+0xd6>
      } else if(c == 'x') {
 8a0:	07a78863          	beq	a5,s10,910 <vprintf+0xf2>
      } else if(c == 'p') {
 8a4:	09b78463          	beq	a5,s11,92c <vprintf+0x10e>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
 8a8:	07300713          	li	a4,115
 8ac:	0ce78563          	beq	a5,a4,976 <vprintf+0x158>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 8b0:	06300713          	li	a4,99
 8b4:	0ee78c63          	beq	a5,a4,9ac <vprintf+0x18e>
        putc(fd, va_arg(ap, uint));
      } else if(c == '%'){
 8b8:	11478663          	beq	a5,s4,9c4 <vprintf+0x1a6>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 8bc:	85d2                	mv	a1,s4
 8be:	8556                	mv	a0,s5
 8c0:	00000097          	auipc	ra,0x0
 8c4:	e8e080e7          	jalr	-370(ra) # 74e <putc>
        putc(fd, c);
 8c8:	85a6                	mv	a1,s1
 8ca:	8556                	mv	a0,s5
 8cc:	00000097          	auipc	ra,0x0
 8d0:	e82080e7          	jalr	-382(ra) # 74e <putc>
      }
      state = 0;
 8d4:	4981                	li	s3,0
 8d6:	b765                	j	87e <vprintf+0x60>
        printint(fd, va_arg(ap, int), 10, 1);
 8d8:	008b0493          	addi	s1,s6,8
 8dc:	4685                	li	a3,1
 8de:	4629                	li	a2,10
 8e0:	000b2583          	lw	a1,0(s6)
 8e4:	8556                	mv	a0,s5
 8e6:	00000097          	auipc	ra,0x0
 8ea:	e8a080e7          	jalr	-374(ra) # 770 <printint>
 8ee:	8b26                	mv	s6,s1
      state = 0;
 8f0:	4981                	li	s3,0
 8f2:	b771                	j	87e <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 8f4:	008b0493          	addi	s1,s6,8
 8f8:	4681                	li	a3,0
 8fa:	4629                	li	a2,10
 8fc:	000b2583          	lw	a1,0(s6)
 900:	8556                	mv	a0,s5
 902:	00000097          	auipc	ra,0x0
 906:	e6e080e7          	jalr	-402(ra) # 770 <printint>
 90a:	8b26                	mv	s6,s1
      state = 0;
 90c:	4981                	li	s3,0
 90e:	bf85                	j	87e <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 910:	008b0493          	addi	s1,s6,8
 914:	4681                	li	a3,0
 916:	4641                	li	a2,16
 918:	000b2583          	lw	a1,0(s6)
 91c:	8556                	mv	a0,s5
 91e:	00000097          	auipc	ra,0x0
 922:	e52080e7          	jalr	-430(ra) # 770 <printint>
 926:	8b26                	mv	s6,s1
      state = 0;
 928:	4981                	li	s3,0
 92a:	bf91                	j	87e <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 92c:	008b0793          	addi	a5,s6,8
 930:	f8f43423          	sd	a5,-120(s0)
 934:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 938:	03000593          	li	a1,48
 93c:	8556                	mv	a0,s5
 93e:	00000097          	auipc	ra,0x0
 942:	e10080e7          	jalr	-496(ra) # 74e <putc>
  putc(fd, 'x');
 946:	85ea                	mv	a1,s10
 948:	8556                	mv	a0,s5
 94a:	00000097          	auipc	ra,0x0
 94e:	e04080e7          	jalr	-508(ra) # 74e <putc>
 952:	44c1                	li	s1,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 954:	03c9d793          	srli	a5,s3,0x3c
 958:	97de                	add	a5,a5,s7
 95a:	0007c583          	lbu	a1,0(a5)
 95e:	8556                	mv	a0,s5
 960:	00000097          	auipc	ra,0x0
 964:	dee080e7          	jalr	-530(ra) # 74e <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 968:	0992                	slli	s3,s3,0x4
 96a:	34fd                	addiw	s1,s1,-1
 96c:	f4e5                	bnez	s1,954 <vprintf+0x136>
        printptr(fd, va_arg(ap, uint64));
 96e:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 972:	4981                	li	s3,0
 974:	b729                	j	87e <vprintf+0x60>
        s = va_arg(ap, char*);
 976:	008b0993          	addi	s3,s6,8
 97a:	000b3483          	ld	s1,0(s6)
        if(s == 0)
 97e:	c085                	beqz	s1,99e <vprintf+0x180>
        while(*s != 0){
 980:	0004c583          	lbu	a1,0(s1)
 984:	c9a1                	beqz	a1,9d4 <vprintf+0x1b6>
          putc(fd, *s);
 986:	8556                	mv	a0,s5
 988:	00000097          	auipc	ra,0x0
 98c:	dc6080e7          	jalr	-570(ra) # 74e <putc>
          s++;
 990:	0485                	addi	s1,s1,1
        while(*s != 0){
 992:	0004c583          	lbu	a1,0(s1)
 996:	f9e5                	bnez	a1,986 <vprintf+0x168>
        s = va_arg(ap, char*);
 998:	8b4e                	mv	s6,s3
      state = 0;
 99a:	4981                	li	s3,0
 99c:	b5cd                	j	87e <vprintf+0x60>
          s = "(null)";
 99e:	00000497          	auipc	s1,0x0
 9a2:	34a48493          	addi	s1,s1,842 # ce8 <digits+0x18>
        while(*s != 0){
 9a6:	02800593          	li	a1,40
 9aa:	bff1                	j	986 <vprintf+0x168>
        putc(fd, va_arg(ap, uint));
 9ac:	008b0493          	addi	s1,s6,8
 9b0:	000b4583          	lbu	a1,0(s6)
 9b4:	8556                	mv	a0,s5
 9b6:	00000097          	auipc	ra,0x0
 9ba:	d98080e7          	jalr	-616(ra) # 74e <putc>
 9be:	8b26                	mv	s6,s1
      state = 0;
 9c0:	4981                	li	s3,0
 9c2:	bd75                	j	87e <vprintf+0x60>
        putc(fd, c);
 9c4:	85d2                	mv	a1,s4
 9c6:	8556                	mv	a0,s5
 9c8:	00000097          	auipc	ra,0x0
 9cc:	d86080e7          	jalr	-634(ra) # 74e <putc>
      state = 0;
 9d0:	4981                	li	s3,0
 9d2:	b575                	j	87e <vprintf+0x60>
        s = va_arg(ap, char*);
 9d4:	8b4e                	mv	s6,s3
      state = 0;
 9d6:	4981                	li	s3,0
 9d8:	b55d                	j	87e <vprintf+0x60>
    }
  }
}
 9da:	70e6                	ld	ra,120(sp)
 9dc:	7446                	ld	s0,112(sp)
 9de:	74a6                	ld	s1,104(sp)
 9e0:	7906                	ld	s2,96(sp)
 9e2:	69e6                	ld	s3,88(sp)
 9e4:	6a46                	ld	s4,80(sp)
 9e6:	6aa6                	ld	s5,72(sp)
 9e8:	6b06                	ld	s6,64(sp)
 9ea:	7be2                	ld	s7,56(sp)
 9ec:	7c42                	ld	s8,48(sp)
 9ee:	7ca2                	ld	s9,40(sp)
 9f0:	7d02                	ld	s10,32(sp)
 9f2:	6de2                	ld	s11,24(sp)
 9f4:	6109                	addi	sp,sp,128
 9f6:	8082                	ret

00000000000009f8 <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
 9f8:	715d                	addi	sp,sp,-80
 9fa:	ec06                	sd	ra,24(sp)
 9fc:	e822                	sd	s0,16(sp)
 9fe:	1000                	addi	s0,sp,32
 a00:	e010                	sd	a2,0(s0)
 a02:	e414                	sd	a3,8(s0)
 a04:	e818                	sd	a4,16(s0)
 a06:	ec1c                	sd	a5,24(s0)
 a08:	03043023          	sd	a6,32(s0)
 a0c:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
 a10:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 a14:	8622                	mv	a2,s0
 a16:	00000097          	auipc	ra,0x0
 a1a:	e08080e7          	jalr	-504(ra) # 81e <vprintf>
}
 a1e:	60e2                	ld	ra,24(sp)
 a20:	6442                	ld	s0,16(sp)
 a22:	6161                	addi	sp,sp,80
 a24:	8082                	ret

0000000000000a26 <printf>:

void
printf(const char *fmt, ...)
{
 a26:	711d                	addi	sp,sp,-96
 a28:	ec06                	sd	ra,24(sp)
 a2a:	e822                	sd	s0,16(sp)
 a2c:	1000                	addi	s0,sp,32
 a2e:	e40c                	sd	a1,8(s0)
 a30:	e810                	sd	a2,16(s0)
 a32:	ec14                	sd	a3,24(s0)
 a34:	f018                	sd	a4,32(s0)
 a36:	f41c                	sd	a5,40(s0)
 a38:	03043823          	sd	a6,48(s0)
 a3c:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
 a40:	00840613          	addi	a2,s0,8
 a44:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 a48:	85aa                	mv	a1,a0
 a4a:	4505                	li	a0,1
 a4c:	00000097          	auipc	ra,0x0
 a50:	dd2080e7          	jalr	-558(ra) # 81e <vprintf>
}
 a54:	60e2                	ld	ra,24(sp)
 a56:	6442                	ld	s0,16(sp)
 a58:	6125                	addi	sp,sp,96
 a5a:	8082                	ret

0000000000000a5c <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 a5c:	1141                	addi	sp,sp,-16
 a5e:	e422                	sd	s0,8(sp)
 a60:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
 a62:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 a66:	00000797          	auipc	a5,0x0
 a6a:	2aa78793          	addi	a5,a5,682 # d10 <freep>
 a6e:	639c                	ld	a5,0(a5)
 a70:	a805                	j	aa0 <free+0x44>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 a72:	4618                	lw	a4,8(a2)
 a74:	9db9                	addw	a1,a1,a4
 a76:	feb52c23          	sw	a1,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 a7a:	6398                	ld	a4,0(a5)
 a7c:	6318                	ld	a4,0(a4)
 a7e:	fee53823          	sd	a4,-16(a0)
 a82:	a091                	j	ac6 <free+0x6a>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 a84:	ff852703          	lw	a4,-8(a0)
 a88:	9e39                	addw	a2,a2,a4
 a8a:	c790                	sw	a2,8(a5)
    p->s.ptr = bp->s.ptr;
 a8c:	ff053703          	ld	a4,-16(a0)
 a90:	e398                	sd	a4,0(a5)
 a92:	a099                	j	ad8 <free+0x7c>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 a94:	6398                	ld	a4,0(a5)
 a96:	00e7e463          	bltu	a5,a4,a9e <free+0x42>
 a9a:	00e6ea63          	bltu	a3,a4,aae <free+0x52>
{
 a9e:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 aa0:	fed7fae3          	bleu	a3,a5,a94 <free+0x38>
 aa4:	6398                	ld	a4,0(a5)
 aa6:	00e6e463          	bltu	a3,a4,aae <free+0x52>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 aaa:	fee7eae3          	bltu	a5,a4,a9e <free+0x42>
  if(bp + bp->s.size == p->s.ptr){
 aae:	ff852583          	lw	a1,-8(a0)
 ab2:	6390                	ld	a2,0(a5)
 ab4:	02059713          	slli	a4,a1,0x20
 ab8:	9301                	srli	a4,a4,0x20
 aba:	0712                	slli	a4,a4,0x4
 abc:	9736                	add	a4,a4,a3
 abe:	fae60ae3          	beq	a2,a4,a72 <free+0x16>
    bp->s.ptr = p->s.ptr;
 ac2:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 ac6:	4790                	lw	a2,8(a5)
 ac8:	02061713          	slli	a4,a2,0x20
 acc:	9301                	srli	a4,a4,0x20
 ace:	0712                	slli	a4,a4,0x4
 ad0:	973e                	add	a4,a4,a5
 ad2:	fae689e3          	beq	a3,a4,a84 <free+0x28>
  } else
    p->s.ptr = bp;
 ad6:	e394                	sd	a3,0(a5)
  freep = p;
 ad8:	00000717          	auipc	a4,0x0
 adc:	22f73c23          	sd	a5,568(a4) # d10 <freep>
}
 ae0:	6422                	ld	s0,8(sp)
 ae2:	0141                	addi	sp,sp,16
 ae4:	8082                	ret

0000000000000ae6 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 ae6:	7139                	addi	sp,sp,-64
 ae8:	fc06                	sd	ra,56(sp)
 aea:	f822                	sd	s0,48(sp)
 aec:	f426                	sd	s1,40(sp)
 aee:	f04a                	sd	s2,32(sp)
 af0:	ec4e                	sd	s3,24(sp)
 af2:	e852                	sd	s4,16(sp)
 af4:	e456                	sd	s5,8(sp)
 af6:	e05a                	sd	s6,0(sp)
 af8:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 afa:	02051993          	slli	s3,a0,0x20
 afe:	0209d993          	srli	s3,s3,0x20
 b02:	09bd                	addi	s3,s3,15
 b04:	0049d993          	srli	s3,s3,0x4
 b08:	2985                	addiw	s3,s3,1
 b0a:	0009891b          	sext.w	s2,s3
  if((prevp = freep) == 0){
 b0e:	00000797          	auipc	a5,0x0
 b12:	20278793          	addi	a5,a5,514 # d10 <freep>
 b16:	6388                	ld	a0,0(a5)
 b18:	c515                	beqz	a0,b44 <malloc+0x5e>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 b1a:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 b1c:	4798                	lw	a4,8(a5)
 b1e:	03277f63          	bleu	s2,a4,b5c <malloc+0x76>
 b22:	8a4e                	mv	s4,s3
 b24:	0009871b          	sext.w	a4,s3
 b28:	6685                	lui	a3,0x1
 b2a:	00d77363          	bleu	a3,a4,b30 <malloc+0x4a>
 b2e:	6a05                	lui	s4,0x1
 b30:	000a0a9b          	sext.w	s5,s4
  p = sbrk(nu * sizeof(Header));
 b34:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 b38:	00000497          	auipc	s1,0x0
 b3c:	1d848493          	addi	s1,s1,472 # d10 <freep>
  if(p == (char*)-1)
 b40:	5b7d                	li	s6,-1
 b42:	a885                	j	bb2 <malloc+0xcc>
    base.s.ptr = freep = prevp = &base;
 b44:	00008797          	auipc	a5,0x8
 b48:	1e478793          	addi	a5,a5,484 # 8d28 <base>
 b4c:	00000717          	auipc	a4,0x0
 b50:	1cf73223          	sd	a5,452(a4) # d10 <freep>
 b54:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 b56:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 b5a:	b7e1                	j	b22 <malloc+0x3c>
      if(p->s.size == nunits)
 b5c:	02e90b63          	beq	s2,a4,b92 <malloc+0xac>
        p->s.size -= nunits;
 b60:	4137073b          	subw	a4,a4,s3
 b64:	c798                	sw	a4,8(a5)
        p += p->s.size;
 b66:	1702                	slli	a4,a4,0x20
 b68:	9301                	srli	a4,a4,0x20
 b6a:	0712                	slli	a4,a4,0x4
 b6c:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 b6e:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 b72:	00000717          	auipc	a4,0x0
 b76:	18a73f23          	sd	a0,414(a4) # d10 <freep>
      return (void*)(p + 1);
 b7a:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 b7e:	70e2                	ld	ra,56(sp)
 b80:	7442                	ld	s0,48(sp)
 b82:	74a2                	ld	s1,40(sp)
 b84:	7902                	ld	s2,32(sp)
 b86:	69e2                	ld	s3,24(sp)
 b88:	6a42                	ld	s4,16(sp)
 b8a:	6aa2                	ld	s5,8(sp)
 b8c:	6b02                	ld	s6,0(sp)
 b8e:	6121                	addi	sp,sp,64
 b90:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 b92:	6398                	ld	a4,0(a5)
 b94:	e118                	sd	a4,0(a0)
 b96:	bff1                	j	b72 <malloc+0x8c>
  hp->s.size = nu;
 b98:	01552423          	sw	s5,8(a0)
  free((void*)(hp + 1));
 b9c:	0541                	addi	a0,a0,16
 b9e:	00000097          	auipc	ra,0x0
 ba2:	ebe080e7          	jalr	-322(ra) # a5c <free>
  return freep;
 ba6:	6088                	ld	a0,0(s1)
      if((p = morecore(nunits)) == 0)
 ba8:	d979                	beqz	a0,b7e <malloc+0x98>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 baa:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 bac:	4798                	lw	a4,8(a5)
 bae:	fb2777e3          	bleu	s2,a4,b5c <malloc+0x76>
    if(p == freep)
 bb2:	6098                	ld	a4,0(s1)
 bb4:	853e                	mv	a0,a5
 bb6:	fef71ae3          	bne	a4,a5,baa <malloc+0xc4>
  p = sbrk(nu * sizeof(Header));
 bba:	8552                	mv	a0,s4
 bbc:	00000097          	auipc	ra,0x0
 bc0:	b72080e7          	jalr	-1166(ra) # 72e <sbrk>
  if(p == (char*)-1)
 bc4:	fd651ae3          	bne	a0,s6,b98 <malloc+0xb2>
        return 0;
 bc8:	4501                	li	a0,0
 bca:	bf55                	j	b7e <malloc+0x98>
